<template>
  <header>
    <div class="l-content">
      <el-button @click="HandlerMenu" plain icon="el-icon-menu" size="mini"></el-button>
      <h3 style="color:#fff;">{{pageurl?pageurl:'首页'}}</h3>
    </div>
    <div class="r-content">
      <div>
        <span style="color:white">欢迎{{username}}，您好！</span>
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          <i class="el-icon-arrow-down el-icon--right" style="color:white"></i>
        </span>
        
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="a">个人中心</el-dropdown-item>
          <el-dropdown-item command="b">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      
      </el-dropdown>
      </div>
    </div>
  </header>
</template>

<script>

export default {
  data() {
    return {
      username:'',
      userImg: ''
    }
  }, 
  created() {
    this.username=sessionStorage.getItem('username')
  },
  methods: {
    handleCommand(command) {  
        if(command=='b'){
          this.$router.push({
            name:'login'
          })
        }if(command=='a'){
          this.$router.push({
          name:'personal'
        })
        }
      },
      HandlerMenu(){
        this.$store.commit('collapseMenu','233')
      },
      
  },computed:{
    
    username(){return this.username},
    pageurl(){return this.$store.state.tab.url}
  }
}
</script>

<style lang="less" scoped>
header {
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;
}

.dropdown {
  float: right;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
.l-content{
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  .el-button{
    margin-right:20px;
  }
}
</style>